package com.weiyuanstudio.nextstep.controller;

import com.weiyuanstudio.nextstep.enums.TaskStatus;
import com.weiyuanstudio.nextstep.persistence.entity.SyncTaskRecord;
import com.weiyuanstudio.nextstep.persistence.repository.SyncTaskRecordRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/api")
public class SyncTaskController {
    SyncTaskRecordRepository syncTaskRecordRepository;

    public SyncTaskController(SyncTaskRecordRepository syncTaskRecordRepository) {
        this.syncTaskRecordRepository = syncTaskRecordRepository;
    }

    @GetMapping("/sync-task")
    public SyncTaskRecord allUser() {
        SyncTaskRecord record = new SyncTaskRecord();
        record.setLogDateTime(LocalDateTime.now());
        record.setTaskStatus(TaskStatus.CREATED);
        return syncTaskRecordRepository.save(record);
    }
}
